 <%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
</head>
<script type="text/javascript">
	$(function(){
		$("#formID").validationEngine({
			showOnMouseOver : true
		});
		$("#btn_save").click(function(){
			var valid = $("#formID").validationEngine('validate');
			if(!valid)
				return;
			var frm = $("form[name='moduleInfoForm']");
			frm.attr("action", "${ctx}/moduleInfoController.do?method=save");
			submit(frm,function(res,status){
				win.window("close");
				if(isSuccess(res,status)){
					grid.datagrid("reload");
					showTip(alertinfo+"成功");
				}else showTip(alertinfo+"失败");
			},function(res,status){
				win.window("close");
				showTip(alertinfo+"失败");
			});
		});
		$("input[name=parentModuleid]").combotree({
			url : "${ctx}/moduleInfoController.do?method=getModuleTree&userid=${userinfo.userid}",
			animate : true
		});
		$("#btn_back").click(function(){
			win.window("close");
		});
	});
	function check(){
		$.ajax({
			type:"post",
			url: "${ctx}/moduleInfoController.do?method=check&moduleName="+encodeURIComponent(encodeURIComponent($("input[name=moduleName]").val())),
			success:function(json){
				if(json){
					var obj = decode(json);
					if (obj.success){
						return true;
					}else{
						alert("该模块名称已存在！");
						$("input[name=moduleName]").val("");
					}
				}
			}
		});
	}
</script>
<body>
	<form action="/moduleInfoController" method="post" name="moduleInfoForm" id="formID">
		<c:if test="${moduleInfo!=null}">
			<input type="hidden" name="moduleid" value="${moduleInfo.moduleid}"/>
		</c:if>
		<div>
			<table class="FormView" border="0" cellspacing="1" cellpadding="0">
				<col class="Label" />
				<col class="Data" />
				<tr>
					<td>模块名称：</td>
					<td><input type="text" name="moduleName" id="moduleName" class="validate[required,maxSize[50]] text" value="${moduleInfo.moduleName}" onchange="check()"/><font color="red">**</font></td> 
				</tr>
				<tr>
					<td>父模块名称：</td>
					<td><input class="text" name="parentModuleid" id="parentModuleid" value="${moduleInfo.parentModuleid}" style="width:168px"/>&nbsp;<img src="${ctx }/js/jquery/images/clean.gif" title="撤销条件"
								onClick="inputClean(this)"
								style="cursor: pointer; width: 14px; height: 10px;"
								align="absmiddle"/></td>
				</tr>
				<tr>
					<td>模块链接：</td>
					<td><input type="text" name="addr" id="addr" class="validate[maxSize[100]] text" value="${moduleInfo.addr}"/></td> 
				</tr>
				<tr>
					<td>模块号：</td>
					<td><input type="text" name="moduleCode" id="moduleCode" class="validate[maxSize[20]] text" value="${moduleInfo.moduleCode}"/></td> 
				</tr>
				<tr>
					<td>模块图标：</td>
					<td><input type="text" name="moduleIcon" id="moduleIcon" class="validate[required,maxSize[20]] text" value="${moduleInfo.moduleIcon }"/><font color="red">**</font></td> 
				</tr>
				<tr>
					<td>模块序号：</td>
					<td><input type="text" name="moduleNo" id="moduleNo" class="validate[required,maxSize[20]] text" value="${moduleInfo.moduleNo }"/><font color="red">**</font></td> 
				</tr>
			</table>
		</div>
	</form>
	<div align="center" class="foot-buttons""
			border="false" align="center">
			<div class="tool-btn" id="btn_save">
				<span class="icon-save">&nbsp;</span>
				保存
			</div>
			<div class="tool-btn" id="btn_back">
				<span class="icon-back">&nbsp;</span>
				返回
			</div>
	</div>
</body>
</html>
